<!DOCTYPE html>


<html theme="dark" showBanner="true" hasBanner="false" > 
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/fontawesome.min.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/brands.min.css" rel="stylesheet">
<link href="https://cdn.staticfile.org/font-awesome/6.4.2/css/solid.min.css" rel="stylesheet">
<script src="/hexo-blog/js/color.global.min.js" ></script>
<script src="/hexo-blog/js/load-settings.js" ></script>
<head>
  <meta charset="utf-8">
  
  
  

  
  <title>bressanone</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

  <link rel="preload" href="/hexo-blog/css/fonts/Roboto-Regular.ttf" as="font" type="font/ttf" crossorigin="anonymous">
  <link rel="preload" href="/hexo-blog/css/fonts/Roboto-Bold.ttf" as="font" type="font/ttf" crossorigin="anonymous">

  <meta property="og:type" content="website">
<meta property="og:title" content="bressanone">
<meta property="og:url" content="http://example.com/page/2/index.html">
<meta property="og:site_name" content="bressanone">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="Zachary">
<meta name="twitter:card" content="summary">
  
  
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-32.png" sizes="32x32">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-128.png" sizes="128x128">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-180.png" sizes="180x180">
    <link rel="icon" media="(prefers-color-scheme: light)" href="/hexo-blog/images/favicon-light-192.png" sizes="192x192">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-32.png" sizes="32x32">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-128.png" sizes="128x128">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-180.png" sizes="180x180">
    <link rel="icon" media="(prefers-color-scheme: dark)" href="/hexo-blog/images/favicon-dark-192.png" sizes="192x192">
  
  
<link rel="stylesheet" href="/hexo-blog/css/style.css">

<meta name="generator" content="Hexo 7.1.1"></head>

<body>
  
   
  <div id="main-grid" class="  ">
    <div id="nav" class=" is_home "  >
      <navbar id="navbar">
  <nav id="title-nav">
    <a href="/hexo-blog/">
      <div id="vivia-logo">
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
        <div class="dot"></div>
      </div>
      <div>bressanone </div>
    </a>
  </nav>
  <nav id="main-nav">
    
      <a class="main-nav-link" href="/hexo-blog/">主页</a>
    
      <a class="main-nav-link" href="/hexo-blog/archives">归档</a>
    
      <a class="main-nav-link" href="/hexo-blog/about">关于</a>
    
  </nav>
  <nav id="sub-nav">
    <a id="theme-btn" class="nav-icon">
      <span class="light-mode-icon"><svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M438.5-829.913v-48q0-17.452 11.963-29.476 11.964-12.024 29.326-12.024 17.363 0 29.537 12.024t12.174 29.476v48q0 17.452-11.963 29.476-11.964 12.024-29.326 12.024-17.363 0-29.537-12.024T438.5-829.913Zm0 747.826v-48q0-17.452 11.963-29.476 11.964-12.024 29.326-12.024 17.363 0 29.537 12.024t12.174 29.476v48q0 17.452-11.963 29.476-11.964 12.024-29.326 12.024-17.363 0-29.537-12.024T438.5-82.087ZM877.913-438.5h-48q-17.452 0-29.476-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537t29.476-12.174h48q17.452 0 29.476 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T877.913-438.5Zm-747.826 0h-48q-17.452 0-29.476-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537T82.087-521.5h48q17.452 0 29.476 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T130.087-438.5Zm660.174-290.87-34.239 32q-12.913 12.674-29.565 12.174-16.653-.5-29.327-13.174-12.674-12.673-12.554-28.826.12-16.152 12.794-28.826l33-35q12.913-12.674 30.454-12.674t30.163 12.847q12.709 12.846 12.328 30.826-.38 17.98-13.054 30.653ZM262.63-203.978l-32 34q-12.913 12.674-30.454 12.674t-30.163-12.847q-12.709-12.846-12.328-30.826.38-17.98 13.054-30.653l33.239-31q12.913-12.674 29.565-12.174 16.653.5 29.327 13.174 12.674 12.673 12.554 28.826-.12 16.152-12.794 28.826Zm466.74 33.239-32-33.239q-12.674-12.913-12.174-29.565.5-16.653 13.174-29.327 12.673-12.674 28.826-13.054 16.152-.38 28.826 12.294l35 33q12.674 12.913 12.674 30.454t-12.847 30.163q-12.846 12.709-30.826 12.328-17.98-.38-30.653-13.054ZM203.978-697.37l-34-33q-12.674-12.913-13.174-29.945-.5-17.033 12.174-29.707t31.326-13.293q18.653-.62 31.326 13.054l32 34.239q11.674 12.913 11.174 29.565-.5 16.653-13.174 29.327-12.673 12.674-28.826 12.554-16.152-.12-28.826-12.794ZM480-240q-100 0-170-70t-70-170q0-100 70-170t170-70q100 0 170 70t70 170q0 100-70 170t-170 70Zm-.247-82q65.703 0 111.475-46.272Q637-414.544 637-480.247t-45.525-111.228Q545.95-637 480.247-637t-111.475 45.525Q323-545.95 323-480.247t45.525 111.975Q414.05-322 479.753-322ZM481-481Z"/></svg></span>
      <span class="dark-mode-icon"><svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M480.239-116.413q-152.63 0-258.228-105.478Q116.413-327.37 116.413-480q0-130.935 77.739-227.435t206.304-125.043q43.022-9.631 63.87 10.869t3.478 62.805q-8.891 22.043-14.315 44.463-5.424 22.42-5.424 46.689 0 91.694 64.326 155.879 64.325 64.186 156.218 64.186 24.369 0 46.978-4.946 22.609-4.945 44.413-14.076 42.826-17.369 62.967 1.142 20.142 18.511 10.511 61.054Q807.174-280 712.63-198.206q-94.543 81.793-232.391 81.793Zm0-95q79.783 0 143.337-40.217 63.554-40.218 95.793-108.283-15.608 4.044-31.097 5.326-15.49 1.283-31.859.805-123.706-4.066-210.777-90.539-87.071-86.473-91.614-212.092-.24-16.369.923-31.978 1.164-15.609 5.446-30.978-67.826 32.478-108.282 96.152Q211.652-559.543 211.652-480q0 111.929 78.329 190.258 78.329 78.329 190.258 78.329ZM466.13-465.891Z"/></svg></span>
    </a>
    
    <div id="nav-menu-btn" class="nav-icon">
      <svg xmlns="http://www.w3.org/2000/svg" height="20" viewBox="0 -960 960 960" width="20"><path d="M177.37-252.282q-17.453 0-29.477-11.964-12.024-11.963-12.024-29.326t12.024-29.537q12.024-12.174 29.477-12.174h605.26q17.453 0 29.477 11.964 12.024 11.963 12.024 29.326t-12.024 29.537q-12.024 12.174-29.477 12.174H177.37Zm0-186.218q-17.453 0-29.477-11.963-12.024-11.964-12.024-29.326 0-17.363 12.024-29.537T177.37-521.5h605.26q17.453 0 29.477 11.963 12.024 11.964 12.024 29.326 0 17.363-12.024 29.537T782.63-438.5H177.37Zm0-186.217q-17.453 0-29.477-11.964-12.024-11.963-12.024-29.326t12.024-29.537q12.024-12.174 29.477-12.174h605.26q17.453 0 29.477 11.964 12.024 11.963 12.024 29.326t-12.024 29.537q-12.024 12.174-29.477 12.174H177.37Z"/></svg>
    </div>
  </nav>
</navbar>
<div id="nav-dropdown" class="hidden">
  <div id="dropdown-link-list">
    
      <a class="nav-dropdown-link" href="/hexo-blog/">主页</a>
    
      <a class="nav-dropdown-link" href="/hexo-blog/archives">归档</a>
    
      <a class="nav-dropdown-link" href="/hexo-blog/about">关于</a>
    
     
    </div>
</div>
<script>
  let dropdownBtn = document.getElementById("nav-menu-btn");
  let dropdownEle = document.getElementById("nav-dropdown");
  dropdownBtn.onclick = function() {
    dropdownEle.classList.toggle("hidden");
  }
</script>
    </div>
    <div id="sidebar-wrapper">
      <sidebar id="sidebar">
  
    <div class="widget-wrap">
  <div class="info-card">
    <div class="avatar">
      
      <div class="img-dim"></div>
    </div>
    <div class="info">
      <div class="username">Zachary </div>
      <div class="dot"></div>
      <div class="subtitle"> </div>
      <div class="link-list">
        
          <a class="link-btn" target="_blank" rel="noopener" href="https://github.com/zzy1661" title="GitHub"><i class="fa-brands fa-github"></i></a>
         
      </div>  
    </div>
  </div>
</div>

  
  <div class="sticky">
    
      


  <div class="widget-wrap">
    <div class="widget">
      <h3 class="widget-title">分类</h3>
      <div class="category-box">
            <a class="category-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">
                前端笔记
                <div class="category-count">78</div>
            </a>
        
            <a class="category-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">
                算法手册
                <div class="category-count">7</div>
            </a>
        </div>
    </div>
  </div>


    
      
  <div class="widget-wrap">
    <div class="widget">
      <h3 class="widget-title">标签</h3>
      <ul class="widget-tag-list" itemprop="keywords"><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Ant-Design/" rel="tag">Ant Design</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/CSS/" rel="tag">CSS</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Canvas/" rel="tag">Canvas</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Docker/" rel="tag">Docker</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/ECMAScript-6/" rel="tag">ECMAScript 6</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/JavaScript/" rel="tag">JavaScript</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Less/" rel="tag">Less</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/MobX/" rel="tag">MobX</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/MongoDB/" rel="tag">MongoDB</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/NPM/" rel="tag">NPM</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/NestJS/" rel="tag">NestJS</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Node-js/" rel="tag">Node.js</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Postman/" rel="tag">Postman</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/React-js/" rel="tag">React.js</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Redux/" rel="tag">Redux</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/TypeScript/" rel="tag">TypeScript</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/UML/" rel="tag">UML</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Webpack/" rel="tag">Webpack</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/Yeoman/" rel="tag">Yeoman</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E5%89%8D%E7%AB%AF/" rel="tag">前端</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%9E%B6%E6%9E%84/" rel="tag">架构</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F/" rel="tag">正则表达式</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E6%BA%90%E7%A0%81/" rel="tag">源码</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E7%88%AC%E8%99%AB/" rel="tag">爬虫</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li><li class="widget-tag-list-item"><a class="widget-tag-list-link" href="/hexo-blog/tags/%E9%9D%A2%E8%AF%95/" rel="tag">面试</a></li></ul>
    </div>
  </div>


    
  </div>
</sidebar>
    </div>
    <div id="content-body">
      
   


<article id="post-@nestjsx crud快速入门" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/18/@nestjsx%20crud%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/">@nestjsx/crud快速入门</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-17T16:00:00.000Z" itemprop="datePublished">2022-02-18</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">前端笔记</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            7.6k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/NestJS/" rel="tag">NestJS</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/Node-js/" rel="tag">Node.js</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第22天，活动详情查看：2022首次更文挑战」
介绍@nestjsx&#x2F;crud 是为NestJs服务的个“微框架”，能大大简化CRUD代码的编写。虽然官方自称为“微框架”，但个人觉得理解为“工具集”可能更合适。
项目初始化首先使用nest脚手架生成一个项目
12npm i -g @nestjs/clinest new curd-demo

然后安装@nestjsx&#x2F;crud的依赖：
12npm i @nestjsx/crud class-transformer class-validatornpm i @nestjsx/crud-typeorm @nestjs/typeorm typeorm

@nestjsx&#x2F;crud和@nestjsx&#x2F;crud-typeorm分别提供了一个@Crud()装饰器和TypeOrmCrudService类，分别作用域controller和service。
配置数据库连接配置TypeORM配置文件在src目录下创建orm.js,这里需要注意配置synchronize: fals...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/18/@nestjsx%20crud%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之计数排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/16/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E8%AE%A1%E6%95%B0%E6%8E%92%E5%BA%8F/">排序算法之计数排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-15T16:00:00.000Z" itemprop="datePublished">2022-02-16</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            1.3k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第21天，活动详情查看：2022首次更文挑战」
介绍前面的算法都是通过比较得到值的位置，但是计数排序并不需要进行比较。基于比较的排序算法，理论上的时间复杂度下限为O(nlog(n))O(nlog(n))O(nlog(n))，而计数排序时间复杂度为O(n+k)O(n+k)O(n+k)。
计数排序的原理时借助一些特殊的数据结构来帮助我们进行排序，比如数组。首先遍历输入数组，得到最大值m，然后创建一个临时数组，然后遍历输入数组，将每个值放入临时数组的下标，最后只要遍历临时数组有哪些下标，就可以得到排序后的结果。
从这个原理可以看出，计数排序有一个前提——整数排序，并且由于需要创建额外的临时数组，它所需要的空间要更多。
实现js实现如下：
1234567891011121314151617181920212223242526272829function findMax(array) &#123;  let max = array[0];  array.forEach(item =&gt; &#123;    item &gt; max &amp;&amp...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/16/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E8%AE%A1%E6%95%B0%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-TypeORM之增删改查" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/15/TypeORM%E4%B9%8B%E5%A2%9E%E5%88%A0%E6%94%B9%E6%9F%A5/">TypeORM之增删改查</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-14T16:00:00.000Z" itemprop="datePublished">2022-02-15</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">前端笔记</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            3.8k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/Node-js/" rel="tag">Node.js</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第20天，活动详情查看：2022首次更文挑战」
Active Record 与 Data MapperTypeORM中有两个模式： Active Record 和 Data Mapper，这两个模式的区别在于查询的方式。
Active RecordActive Record可以通过模型访问数据库：
1234567891011const user = new User();user.firstName = &quot;Timber&quot;;// 保存await user.save();// 删除await user.remove();// 查询const users = await User.find(&#123; skip: 2, take: 5 &#125;);const timber = await User.findOne(&#123; firstName: &quot;Timber&quot;, lastName: &quot;Saw&quot; &#125;);

要使用Active Record，entity 必须要继承BaseE...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/15/TypeORM%E4%B9%8B%E5%A2%9E%E5%88%A0%E6%94%B9%E6%9F%A5/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-TypeORM 快速入门" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/14/TypeORM%20%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/">TypeORM 快速入门</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-13T16:00:00.000Z" itemprop="datePublished">2022-02-14</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">前端笔记</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            2.1k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/Node-js/" rel="tag">Node.js</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第19天，活动详情查看：2022首次更文挑战」
介绍TypeORM 是一个ORM框架。ORM(Object–relational mapping) 是指对象关系映射，是一种将某种编程语言中的对象转换为其他不兼容系统中的数据。ORM最常见使用便是对象与数据库表之间的转换。
通常一个ORM框架会有这些能力：

定义实体类
连接数据库
能够根据实体类结构生成表结构，或者能够根据表结构生成实体对象
生成curd代码或减少curd代码的编写

本文介绍Node.js中最常用的ORM框架——TypeORM。
初始化项目TypeORM提供了很多方便的命令，因此首先全局安装typeorm
1npm install typeorm -g

typeorm 的init命令可以快速创建一个项目：
1typeorm init --name typeorm-demo1 --database mysql

如果使用docker，可以加上--docker参数
1typeorm init --docker

这会生成docker-compose.yml文件：

目录结构使用in...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/14/TypeORM%20%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之快速排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/13/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F/">排序算法之快速排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-12T16:00:00.000Z" itemprop="datePublished">2022-02-13</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            1.2k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第18天，活动详情查看：2022首次更文挑战」
介绍快排算法是最常用的算法之一，它的复杂度是O(nlog(n))O(nlog(n))O(nlog(n))。
快排算法步骤比较复杂，这里总结一下它大致的思路：

从数组中去一个值作为主元pivot
创建两个指针，分别从左和右开始，将指针指向的值与主元pivot比较
如果左指针指向的值&gt;pivot,则将这个值与右指针指向的值交换；同理如果右指针指向的数比pivot更大，则将其与左指针指向的数交换
直到两个指针交叉 上面的过程称之为划分partition，这一步结束后可以得到两个数组：较小值数组和较大值数组。

比如3,5,2,4,1，我们去中间值2作为pivot，第一次划分得到的结果是：1,5,2,4,3，过程中进行了2次交换，意味着左边2个数是比pivot更小的，因此这里将数组划分为1,2和5,4,3两个部分。
然后再分别对左右两个数组进行划分，最终得到排序后的结果。
实现1234567891011121314151617181920212223242526272829303132333435f...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/13/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%BF%AB%E9%80%9F%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之归并排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/12/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%BD%92%E5%B9%B6%E6%8E%92%E5%BA%8F/">排序算法之归并排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-11T16:00:00.000Z" itemprop="datePublished">2022-02-12</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            1.4k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第17天，活动详情查看：2022首次更文挑战」
介绍归并排序是第一个可以实际使用的排序算法，它的复杂度是O(nlog(n))O(nlog(n))O(nlog(n))。前面三种排序算法的复杂度都是O(n2)O(n^2)O(n2)，在最坏的情况下，每个数都要和其他任意一个数比较，但归并算法不需要。
归并排序是一种分而治之算法。其思想是将原始数组切分成较小的数组，直到每个小数组只有一个位置，接着将小数组归并成较大的数组，直到最后只有一个排序完毕的大数组。
这里举一个最简单的例子来解释为什么归并算法的性能比前面三种更好：
比如排序3,1,4,2，则可以分为两组：3和1排序得1,3；4和2排序得2,4，之后再将这两组合并，1和2比，可以确定1的位置，而不用再与4比较，从而节省1次比较。
可以从下面的两个图理解归并算法分组——排序——合并的过程：


实现根据归并算法的思想，我们需要将排序函数分为两个部分：分组和排序合并。
12345678910111213141516171819202122function mergeSort(array, compare...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/12/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%BD%92%E5%B9%B6%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之插入排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/11/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E6%8F%92%E5%85%A5%E6%8E%92%E5%BA%8F/">排序算法之插入排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-10T16:00:00.000Z" itemprop="datePublished">2022-02-11</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            917 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第16天，活动详情查看：2022首次更文挑战」
介绍插入排序是依次取出一个数，并和前面的数比较大小，插入到合适的位置。
就好像我们手动整理一副乱序的扑克，先将第2张和第1张比，如果比第1张小，则放在它前面；然后将第3张和第2张比，如果比它小，再和第1张比，如果比它大，则插入到第2和第1张中间。

实现js代码实现如下：
123456789101112131415161718function insertSort(array) &#123;  const &#123; length &#125; = array;  // 这里从第2个数开始往前比  for (let i = 1; i &lt; length; i++) &#123;    let j = i;    // 后续计算的过程会修改i位置的值，因此需要保存一个临时变量    const temp = array[i]    while (j &gt; 0 &amp;&amp; array[j - 1] &gt; temp) &#123;      // 如果前一个数小于待插入的数，则将前...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/11/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E6%8F%92%E5%85%A5%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之选择排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/10/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E9%80%89%E6%8B%A9%E6%8E%92%E5%BA%8F/">排序算法之选择排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-09T16:00:00.000Z" itemprop="datePublished">2022-02-10</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            909 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第15天，活动详情查看：2022首次更文挑战」
介绍选择排序算法是一种原址比较排序算法。选择排序大致的思路是找到数据结构中的最小值并将其放置在第一位，接着找到第二小的值并将其放在第二位，以此类推。
排序算法的执行过程可以参考下图（红色标注的变化就是最小值寻找的过程）：

实现我们需要实现的，是一个不断寻找最小值并交换顺序的过程。
首先从第一位开始往后比较，得到第一个最小值，并将它和首位交换；之后从第二位开始，寻找最小值，并将它和第二位数交换，依次往下，直到最后。因此这里也需要两层循环，实现如下：
1234567891011121314151617181920function selectionSort(array) &#123;  const &#123; length &#125; = array;  let indexMin;  for (let i = 0; i &lt; length - 1; i++) &#123;    // 设置当前最小值的下标为i(初始为0)    indexMin = i;    for (let j = i+1...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/10/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E9%80%89%E6%8B%A9%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-排序算法之冒泡排序" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/09/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F/">排序算法之冒泡排序</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-08T16:00:00.000Z" itemprop="datePublished">2022-02-09</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E7%AE%97%E6%B3%95%E6%89%8B%E5%86%8C/">算法手册</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            1k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E7%AE%97%E6%B3%95/" rel="tag">算法</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第14天，活动详情查看：2022首次更文挑战」
介绍如果要学习排序算法，大多会先从冒泡算法开始，因为它是所有排序算法中最简单的一个。不过它也是最慢的一个。
冒泡排序比较所有相邻的两个项，如果第一个比第二个大，则交换它们。元素项向上移动至正确的顺序，就好像气泡升至表面一样，冒泡排序因此得名。

实现冒泡算法依次比较相邻两项，判断大小，并做交换。每一轮都只能确定一个数字的位置，因此如果有n个数，需要比较n轮。算法实现如下：
12345678910111213function bubbleSort(array) &#123;  const &#123; length &#125; = array;  for (let i = 0; i &lt; length; i++) &#123;    for (let j = 0; j &lt; length - 1; j++) &#123;      if (array[j] &gt; array[j + 1]) &#123;        [array[j], array[j + 1]] = [array[j...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/09/%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E4%B9%8B%E5%86%92%E6%B3%A1%E6%8E%92%E5%BA%8F/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>






   


<article id="post-架构方法之C4模型" class="h-entry article article-type-post" itemprop="blogPost" itemscope itemtype="https://schema.org/BlogPosting">
   
  <div class="article-inner">
    <div class="article-main">
      <header class="article-header">
        
<div class="main-title-bar">
  <div class="main-title-dot"></div>
  
    
      <h1 itemprop="name">
        <a class="p-name article-title" href="/hexo-blog/2022/02/08/%E6%9E%B6%E6%9E%84%E6%96%B9%E6%B3%95%E4%B9%8BC4%E6%A8%A1%E5%9E%8B/">架构方法之C4模型</a>
      </h1>
    
  
</div>

        <div class='meta-info-bar'>
          <div class="meta-info">
  <time class="dt-published" datetime="2022-02-07T16:00:00.000Z" itemprop="datePublished">2022-02-08</time>
</div>
          <div class="need-seperator meta-info">
            <div class="meta-cate-flex">
  
  <a class="meta-cate-link" href="/hexo-blog/categories/%E5%89%8D%E7%AB%AF%E7%AC%94%E8%AE%B0/">前端笔记</a>
   
</div>
  
          </div>
          <div class="wordcount need-seperator meta-info">
            1.1k 词 
          </div>
        </div>
        
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo-blog/tags/%E6%9E%B6%E6%9E%84/" rel="tag">架构</a></li></ul>

      </header>
      <div class="e-content article-entry" itemprop="articleBody">
        
          <div class="truncate-text">
            
              「这是我参与2022首次更文挑战的第13天，活动详情查看：2022首次更文挑战」
前言Simon Brown在《程序员必读之软件架构》中介绍了一种建模方法：C4模型。我觉得这是一种简单但很实用的架构方法，无论是在做软件设计还是做产品设计都可以借鉴这个模型思考。
介绍C4模型认为，大多数软件系统都可以划分为4个层次：

系统 也称系统上下文或语境。这一层标识环境、参与者、外部软件系统和软件系统。
容器 容器可以是应用程序、数据存储、微服务等，它标识高维度上的技术选择，以及各容器的职责划分、如何通信。
组件 将单个容器放大，显示其中关键逻辑组件及它们间的关系。
代码 这一层即最直接的代码，包括接口和类。


系统上下文（语境图）给软件系统画图和做文档时，语境图是很有用的起点，让你可以后退一步观察大局。
语境图中间以一个简单的框图展示你的系统，周围是它的用户和其他与之相互作用的系统。

语境图需要回答这三个问题：

我们构建的（或已经构建的）软件系统是什么？
谁会用它？
如何融入已有的IT环境？ 我们可以从下面几个维度进行整理和标注：


用户与角色：有哪些人会使用这个系统，分别扮演什...
            
          </div>
        
      </div>

         
    </div>
    
     
    <a class="right-panel  non-pic  "
      
      href="/hexo-blog/2022/02/08/%E6%9E%B6%E6%9E%84%E6%96%B9%E6%B3%95%E4%B9%8BC4%E6%A8%A1%E5%9E%8B/" 
    >
       
      <i class="fa-solid fa-angle-right non-pic"></i>
       
    </a>
     
  </div>
  
</article>







  <nav id="page-nav">
    <!-- 在第二页时 page.prev_link 不知为何无法返回正确的链接 -->
    <a id="prev-btn" class="page-nav-btn " href=" /hexo-blog/  ">
      <i class="fa-solid fa-angle-left"></i>
    </a>
    <div id="num-bar">
      <a class="page-number" href="/hexo-blog/">1</a><span class="page-number current">2</span><a class="page-number" href="/hexo-blog/page/3/">3</a><a class="page-number" href="/hexo-blog/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/hexo-blog/page/10/">10</a>  
    </div>
    <a id="next-btn" class="page-nav-btn " href="/hexo-blog/page/3/">
      <i class="fa-solid fa-angle-right"></i>
    </a>
  </nav>


    </div>
    <div id="footer-wrapper">
      <footer id="footer">
  
  <div id="footer-info" class="inner">
    
    &copy; 2024 Zachary<br>
    <!-- Powered by <a href="https://hexo.io/" target="_blank">Hexo</a> & Theme <a target="_blank" rel="noopener" href="https://github.com/saicaca/hexo-theme-vivia">Vivia</a> -->
      <a target="_blank" rel="noopener" href="https://beian.miit.gov.cn">苏ICP备20030005号-2</a>
  </div>
</footer>

    </div>
    <div class="back-to-top-wrapper">
    <button id="back-to-top-btn" class="back-to-top-btn hide" onclick="topFunction()">
        <i class="fa-solid fa-angle-up"></i>
    </button>
</div>

<script>
    function topFunction() {
        window.scroll({ top: 0, behavior: 'smooth' });
    }
    let btn = document.getElementById('back-to-top-btn');
    function scrollFunction() {
        if (document.body.scrollTop > 600 || document.documentElement.scrollTop > 600) {
            btn.classList.remove('hide')
        } else {
            btn.classList.add('hide')
        }
    }
    window.onscroll = function() {
        scrollFunction();
    }
</script>

  </div>
  <script src="/hexo-blog/js/light-dark-switch.js"></script>
</body>
</html>
